import 'package:flutter/cupertino.dart';
import 'package:flutter_bmflocation/flutter_bmflocation.dart';
import 'package:flutter_module/map/map_manager.dart';
import 'package:flutter_module/system/log_util.dart';

class MapControlViewModel with ChangeNotifier {
  bool tracking = true;

  ///定位信息
  BaiduLocation? baiduLocation;

  void initMapEventCallback() {
    ///监听用户操作了地图，解除跟踪模式
    MapManager.instance.mapController.setMapEventCallback((mapEvent) {
      setTracking(false);
    });

  }

  void setTracking(bool track) {
    if (tracking != track) {
      tracking = track;
      notifyListeners();
    }
  }

  ///保存当前位置
  void setLocation(BaiduLocation result) {
    baiduLocation = result;
    LogUtil.instance.printf("更新位置", tag: "Provider");
    notifyListeners();
  }
}
